<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="fragment :: myhead(~{::title},~{})">
    <title >测试 Wang Editor</title>
</head>
<fieldset class="layui-elem-field" style="margin-top: 30px;">
    <legend>文本编辑</legend>
    <div>
        <button id="btn_html" class="layui-btn layui-btn-small" onclick="showHtml()">获取Html</button>
        <button id="btn_text" class="layui-btn layui-btn-small" onclick="showText()">获取Text</button>
    </div>
    <div class="layui-field-box" id="editor"></div>
</fieldset>
<script th:src="@{/wangeditor/wangEditor.js}"></script>
<script type="text/javascript">
    var ctx = '[[@{/}]]';
    var E = window.wangEditor
    var editor = new E('#editor')
    editor.customConfig.uploadImgServer = ctx + 'example/edit/upload?wang=true'
    editor.customConfig.uploadFileName = 'file'
    editor.create()

    function showHtml() {
        alert(editor.txt.html());
    }

    function showText(){
        alert(editor.txt.text());
    }

</script>

</body>
</html>